<?php include('login/trancar.php'); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<?php
		$titulo = "Controle &raquo; Ver Entradas";
		$data = date("d-m-Y");
		require_once ("includes/header.php"); 
	?>
	<script type="text/javascript" src="includes/js/data.js"></script>
</head>
<body>
			<?php 
				include('includes/topoemenu.php');
				require_once('includes/db.php');
			?>
			
			<div id="principal">
			
						<table cellspacing="3px" align="center">
							<tbody>
								<tr>
									<td class='td' style="font-weight:bold;">Codigo OS</td>
									<td class='td' style="font-weight:bold;">Cliente</td>    
                                                                        <td class='td' style="font-weight:bold;">Cliente PJ</td>
                                                                        <td class='td' style="font-weight:bold;">Data</td>
									<td class='td' style="font-weight:bold;">Tipo Atendimento</td>
									<td class='td' style="font-weight:bold;">Status</td>					
								</tr>
				<?php
                        $sqlentra = mysql_query("SELECT *,date_format(Data_Entrada, '%d/%m/%Y') AS Data_Entrada FROM tb_os WHERE Status = 'aberto' and Tipo_Cliente = 'Pessoa Juridica' ORDER BY Numero desc LIMIT 200")or die(mysql_error());
						while($result = mysql_fetch_array($sqlentra))
						{
							$codigocliente = $result['Cliente'];
							$sqlpj = mysql_query("SELECT Razao_Social, Codigo FROM tb_pj WHERE CNPJ = $codigocliente")or die(mysql_error());
							$achafor = mysql_fetch_array($sqlpj);
                                                        
							
							
							echo "<tr>";
							echo "<td class='td'>".$result['Numero']."</td>";
                                                        echo "<td class='td'>".$result['Cliente']."</td>";						
                                                        echo "<td class='td'>".$achafor['Razao_Social']."</td>";
                                                        echo "<td class='td'>".$result['Data_Entrada']."</td>";
							
							echo "<td class='td'>".$result['Tipo_Atendimento']."</td>";
                                                        echo "<td class='td'>".$result['Status']."</td>";
							
					?>
							
					<?php
							echo "</tr>";						
						}	//fim do while
							
						echo "</tbody>";
					echo "</table>";	
						//fim do else, linha 198
					//fim do else p exibir os links, linha 125
				?>
			</div> <!-- Fim da div#principal -->
			
			<?php include('includes/fimerodape.php'); ?>
			
</body>
</html>
